package com.example.dellpc.myapplication;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;

import com.hb.views.PinnedSectionListView;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by dellpc on 2016/8/15.
 */
public class PinnedSectionListViewActivity extends Activity {

    private PinnedSectionListView pinnedSectionListView;
    private List<Item> items;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.pinnedsectionlistview);
        initView();
    }

    public void initView() {
        initDatas();

        String[] datas = new String[]{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q"};
        pinnedSectionListView = (PinnedSectionListView) findViewById(R.id.listview);
        pinnedSectionListView.setAdapter(new MyPinnedSectionListViewAdapter(items,this ));

    }

    public void initDatas() {
        items = new ArrayList<>();
        items.add(new Item(1, "A"));
        for (int j = 0; j < 10; j++) {
            items.add(new Item(0, "A" + j));
        }
        items.add(new Item(1, "B"));
        for (int j = 0; j < 10; j++) {
            items.add(new Item(0, "B" + j));
        }
        items.add(new Item(1, "C"));
        for (int j = 0; j < 10; j++) {
            items.add(new Item(0, "C" + j));
        }
        items.add(new Item(1, "D"));
        for (int j = 0; j < 10; j++) {
            items.add(new Item(0, "D" + j));
        }
        items.add(new Item(1, "E"));
        for (int j = 0; j < 10; j++) {
            items.add(new Item(0, "E" + j));
        }

    }

    public static class Item {
        public static int ITEM = 0;

        public static int TITLE = 1;

        public int type;

        public String text;

        public Item(int type, String text) {
            this.type = type;
            this.text = text;
        }
    }
}
